<?php

	if ($_POST['txt_url']){
            
		$token = $_COOKIE['token'];
		
		mysql_query("INSERT INTO url(origin, microurl, token, clic) VALUES ('".mysql_real_escape_string($_POST['txt_url'])."', '".basename(tempnam("", ""))."', '".$token."', 0)");
    
		if(!isAjax()) {
		  header("Location: ../index.php");die();
    } else {
      $id = mysql_insert_id();
      $result = mysql_fetch_assoc(mysql_query('SELECT * FROM url WHERE id='.$id));
      
            
    }
	}

?>